package work.linruchang.oauthresourceproject.config.oauth;

/**
 * 当前线程的信息
 * （一般在过滤器阶段进行设置）
 *
 * @author LinRuChang
 * @version 1.0
 * @date 2022/08/19
 * @since 1.8
 **/
public class ThreadLocalRequestInfo {

    /**
     * 当前请求用户 == 用于本系统用户  userName字段
     */
    private static ThreadLocal<String> currentUserNameThreadLocal = new ThreadLocal<>();

    /**
     * 当前请求用户 == 用于本系统用户  user的id字段
     */
    private static ThreadLocal<String> currentUserIdThreadLocal = new ThreadLocal<>();


    /**
     * 用于客户端系统的oauth认证  clientId字段
     */
    private static ThreadLocal<String> clientIdThreadLocal = new ThreadLocal<>();

    /**
     * 用于客户端系统的oauth认证  clientSecret字段
     */
    private static ThreadLocal<String> clientSecretThreadLocal = new ThreadLocal<>();


    public static void setUserName(String userName) {
        currentUserNameThreadLocal.set(userName);
    }

    public static String getUserName() {
        return currentUserNameThreadLocal.get();
    }

    public static void setUserId(String userId) {
        currentUserIdThreadLocal.set(userId);
    }

    public static String getUserId() {
        return currentUserIdThreadLocal.get();
    }


    public static void setClientId(String clientId) {
        clientIdThreadLocal.set(clientId);
    }

    public static String getClientId() {
        return clientIdThreadLocal.get();
    }

    public static void setClientSecret(String clientSecret) {
        clientSecretThreadLocal.set(clientSecret);
    }

    public static String getClientSecret() {
        return clientSecretThreadLocal.get();
    }
}
